//
//  ZZXAboutViewController.m
//  Travel
//
//  Created by dllo on 15/12/1.
//  Copyright © 2015年 doll. All rights reserved.
//

#import "ZZXAboutViewController.h"


@interface ZZXAboutViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong)UITableView *tableView;
@property (nonatomic, strong)NSMutableArray *dataArr;
@property (nonatomic, strong)UIImageView *backImg;

@end

@implementation ZZXAboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addScreenEdgePan];
    self.view.backgroundColor = [UIColor colorWithRed:0.98 green:0.97 blue:0.93 alpha:1];
    
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"leftBack"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(backToLast)];
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, CWIDTH, CHEIGHT) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.contentInset = UIEdgeInsetsMake(260, 0, 0, 0);
    //self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.backgroundColor = [UIColor colorWithRed:0.98 green:0.97 blue:0.93 alpha:1];
    [self.view addSubview:self.tableView];
   
    
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, CHEIGHT - 380, CWIDTH, 40)];
    label.text = @" Copyright © 2015 cao kong zhang. All rights reserved";
    label.textColor = [UIColor blackColor];
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:10];
    [self.tableView addSubview:label];
    
    
    //设置tableView的contentView距离上边界264
    self.backImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, -260, CWIDTH, 260)];
    //      [self.backImg sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil];
    self.backImg.contentMode = UIViewContentModeScaleAspectFill;//设置img高度改变时 宽度也改变
    self.backImg.image = [UIImage imageNamed:@"about"];
    //裁剪
    self.backImg.clipsToBounds = YES;
    self.backImg.userInteractionEnabled = YES;
    [self.tableView addSubview:self.backImg];
   
    
    self.dataArr = [@[@"意见反馈", @"版本更新"]mutableCopy];
}

#pragma mark - 自定义按钮触发方法
- (void)backToLast
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    cell.textLabel.text = self.dataArr[indexPath.row];
    cell.backgroundColor = [UIColor colorWithRed:0.98 green:0.97 blue:0.93 alpha:1];
    return cell;
}

//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    if (indexPath.row == 0) {
//        [UMFeedback feedbackViewController].hidesBottomBarWhenPushed = YES;
//        [self.navigationController pushViewController:[UMFeedback feedbackViewController] animated:YES];
//    }
//    else if (indexPath.row == 1)
//    {
//        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:@"暂无更新 敬请期待" preferredStyle:UIAlertControllerStyleAlert];
//        [self presentViewController:alert animated:YES completion:^{
//            
//            [self performSelector:@selector(alertDismiss) withObject:alert afterDelay:1];
//            
//        }];
//        
//    }
//}



#pragma mark - 视图将要出现 夜间模式
//- (void)viewWillAppear:(BOOL)animated
//{
//    [super viewWillAppear: animated];
//    
//    if ([[NSUserDefaults standardUserDefaults]boolForKey:@"isNight"])
//    {
//        self.tableView.backgroundColor = [UIColor colorWithRed:0.28 green:0.28 blue:0.28 alpha:1];
//        self.view.backgroundColor = [UIColor colorWithRed:0.28 green:0.28 blue:0.28 alpha:1];
//    }
//    else
//    {
//        self.tableView.backgroundColor = [UIColor colorWithRed:0.98 green:0.97 blue:0.93 alpha:1];
//        self.view.backgroundColor = [UIColor colorWithRed:0.98 green:0.97 blue:0.93 alpha:1];
//    }
//    [self.tableView reloadData];
//    

//}


// 延迟消失
- (void)alertDismiss
{
    //alertView消失
    [self dismissViewControllerAnimated:YES completion:^{}];
    
}
//- (void)viewWillDisappear:(BOOL)animated
//{
//    [UMFeedback feedbackViewController].hidesBottomBarWhenPushed = YES;
//}
#pragma mark-滑动手势1
- (void)addScreenEdgePan
{
    UIScreenEdgePanGestureRecognizer *screenEdgePan = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(presentLeftMenuViewController:)];
    screenEdgePan.edges = UIRectEdgeLeft;
    [self.view addGestureRecognizer:screenEdgePan];
    [self.tableView addGestureRecognizer:screenEdgePan];
    
}
#pragma mark-滑动手势2
-(void)presentLeftMenuViewController:(UIScreenEdgePanGestureRecognizer *)edge
{
    [self.navigationController popViewControllerAnimated:YES];
}

    
    
    
    


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
